package sg.edu.nus.iss.umpire.support;

import javax.persistence.EntityManager;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import sg.edu.nus.iss.umpire.domain.Umpire;

/**
 * request scoped.
 * 
 */
public interface ServiceContext {

	HttpServletRequest getRequest();

	HttpServletResponse getResponse();

	/**
	 * 
	 * @return the EntityManage associated with this request. an transaction is
	 *         automatically started also.
	 * 
	 *         you do NOT need to manually manage the transaction. it will be
	 *         automatically committed or rolled back at the end of the request
	 */
	EntityManager getEntityManager();

	Umpire getUserSession();
	
	/**
	 * to commit the current transaction associated with the context. the EntityManager is also closed. 
	 * it is to tackle cross-group transactio issue.
	 * Note : the getEntityManager() will return a new EntityManager when called nexttime.
	 */
	void commitCurrentTransaction();
}
